﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Jayden.Dll.ECMAScript
{
	public class Function : StatementList
	{
		private string m_Name;
		private List<string> m_Parameters;

		public Function(string name, params string[] parameters)
		{
			m_Name = name;
			m_Parameters = new List<string>();
			m_Parameters.AddRange(parameters);
		}

		public override void RenderStatement(int level, StringBuilder builder)
		{
			StatementList.AppendSpacing(level, "\t", builder);
			builder.AppendFormat("function {0}({1}) {{", m_Name, string.Join(", ", m_Parameters));
			builder.AppendLine();
			base.RenderStatement(level + 1, builder);
			StatementList.AppendSpacing(level, "\t", builder);
			builder.AppendLine("}");
		}
	}
}
